﻿/*用户信息表*/
CREATE TABLE [dbo].[BaseUsr](
	[Id]		[int]			IDENTITY(1,1) NOT NULL,																	/*自动编号*/
	[SId]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NOT NULL,														/*系统编号*/
	[UsrName]	[varchar](50)	COLLATE Chinese_PRC_CI_AS NOT NULL,														/*用户名称*/
	[Password]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_BaseUsr_Password]  DEFAULT ((123456)),	/*用户口令*/
 CONSTRAINT [PK_BaseUsr] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*公司信息表*/
CREATE TABLE [dbo].[CompanyInfor](
	[Id]			[int]			IDENTITY(1,1) NOT NULL,				/*自动编号*/
	[CName]			[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,		/*公司名称*/
	[Address]		[varchar](200)	COLLATE Chinese_PRC_CI_AS NULL,		/*公司地址*/
	[Legal]			[varchar](10)	COLLATE Chinese_PRC_CI_AS NULL,		/*负责人  */
	[Tel]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*电话    */
	[Fax]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*传真    */
	[Email]			[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,		/*Email   */
	[Website]		[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,		/*网址    */
	[Introduction]	[varchar](200)	COLLATE Chinese_PRC_CI_AS NULL,		/*简介    */
	[Bank]			[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,		/*开户行  */
	[BName]			[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,		/*户名    */
	[Account]		[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,		/*帐号    */
 CONSTRAINT [PK_CompanyInfor] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*仓库信息表*/
CREATE TABLE [dbo].[Warehouse](
	[Id]			[int]			IDENTITY(1,1) NOT NULL,				/*自动编号*/
	[SId]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NOT NULL,	/*系统编号*/
	[Name]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*仓库名称*/
	[Address]		[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,		/*仓库地址*/
	[Tel]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*仓库电话*/
	[EmployeeId]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*库管员*/
 CONSTRAINT [PK_WAREHOUSE] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*员工信息表*/
CREATE TABLE [dbo].[Employee](
	[Id]			[int] IDENTITY(1,1)	NOT NULL,						/*自动编号*/
	[SId]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*系统编号*/
	[Name]			[varchar](8)	COLLATE Chinese_PRC_CI_AS NULL,		/*员工姓名*/
	[Birthday]		[datetime]		NULL,								/*出生日期*/
	[Department]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*部门*/
	[Post]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*职务*/
	[Tel]			[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*电话*/
	[Mobile]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*手机*/
	[Address]		[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,		/*住址*/
	[Hometel]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,		/*宅电*/
	[Email]			[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,		/*电子邮件*/
	[Remark]		[varchar](200)	COLLATE Chinese_PRC_CI_AS NULL,		/*备注*/
	[CDate]			[datetime]		NULL DEFAULT (getdate()),			/*创建日期*/
 CONSTRAINT [PK_EMPLOYEE] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*供应商信息*/
CREATE TABLE [dbo].[Suppliers](
	[Id]		[int]			IDENTITY(1,1) NOT NULL,					/*自动编号*/
	[SId]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*系统编号*/
	[Name]		[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,			/*供应商名称*/
	[Tel]		[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,			/*电话*/
	[Fax]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*传真*/
	[Website]	[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,			/*网址*/
	[Zipcode]	[varchar](10)	COLLATE Chinese_PRC_CI_AS NULL,			/*邮编*/
	[Area]		[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,			/*地区编号*/
	[Address]	[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,			/*通讯地址*/
	[Contact]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*联系人*/
	[CTel]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*联系人电话*/
	[CMobile]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*联系人手机*/
	[CEmail]	[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,			/*联系人邮件*/
	[Bank]		[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,			/*开户行*/
	[BName]		[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,			/*户名*/
	[Account]	[varchar](100)	COLLATE Chinese_PRC_CI_AS NULL,			/*帐号*/
	[BDate]		[datetime]		NULL,									/*期初日期*/
	[BAmount]	[real]			NULL,									/*期初金额*/
	[OCode]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*操作码*/
	[CDate]		[datetime]		NOT NULL DEFAULT (getdate()),			/*创建日期*/
 CONSTRAINT [PK_SUPPLIERS] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

GO
/*用户从属表*/
CREATE TABLE [dbo].[Subjection](
	[Id]		[int]			IDENTITY(1,1) NOT NULL,					/*自动编号*/
	[UsrId]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*用户编号*/
	[ChildId]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*从属编号*/
 CONSTRAINT [PK_Subjection] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*模块登记表*/
CREATE TABLE [dbo].[ModelInfo](
	[Id]		[int]			IDENTITY(1,1) NOT NULL,					/*自动编号*/
	[SId]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NOT NULL,		/*系统编号*/
	[MName]		[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,			/*模块名称*/
	[MIndex]	[int]			NULL,									/*模块索引*/
 CONSTRAINT [PK_ModelInfo] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*组信息表*/
CREATE TABLE [dbo].[GroupInfo](
	[Id]		[int]			IDENTITY(1,1) NOT NULL,					/*自动编号*/
	[SId]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*系统编号*/
	[GName]		[varchar](50)	COLLATE Chinese_PRC_CI_AS NULL,			/*组名称*/
	[GPower]	[varchar](200)	COLLATE Chinese_PRC_CI_AS NULL,			/*组权限*/
 CONSTRAINT [PK_GroupInfo] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

/*组用户对照*/
CREATE TABLE [dbo].[GroupUsr](
	[Id]		[int]			IDENTITY(1,1) NOT NULL,					/*自动编号*/
	[GroupId]	[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*组编号*/
	[UsrId]		[varchar](20)	COLLATE Chinese_PRC_CI_AS NULL,			/*用户编号*/
 CONSTRAINT [PK_GroupUsr] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO